<div ng-controller="WebOfRegistriesController" ng-init="showAddRegistryForm=false" style="height: 580px">
    <div class="pad_top">
        <button type="button" class="ice-button" ng-click="enableDisableWor()">
            <span ng-if="isWorEnabled">Disable</span>
            <span ng-if="!isWorEnabled">Enable</span>
            <i style="font-size: 14px" class="fa fa-fw"
               ng-class="{'fa-toggle-on green':isWorEnabled, 'fa-toggle-off':!isWorEnabled}"></i>
        </button>
        <button type="button" class="ice-button" ng-click="showAddRegistryForm=true" ng-show="isWorEnabled">
            Add Partner
        </button>

        <div class="pull-right wor-admin-only" ng-click="restrictPublicEnable()">
            <i class="fa fa-fw fa-question-circle cursor_default"
               uib-tooltip="Only admins can make an entry/folder public"></i>
            <small>Admins only</small>
            <i class="fa fa-fw" ng-class="{'fa-toggle-on green':restrictPublic, 'fa-toggle-off':!restrictPublic}"></i>
        </div>

        <div class=" margin-top-10 panel panel-default font-95em" ng-show="showAddRegistryForm">
            <form class="panel-body" role="form" ng-submit="addWebPartner()">
                <div class="col-md-2 pad-top-5">
                    <span style="white-space:nowrap">Registry Name <span class="required">*</span> </span>
                </div>
                <div class="col-md-10 pad-top-5">
                    <input placeholder="Unique display identifier" type="text" class="input_box"
                           ng-model="newPartner.name"
                           maxlength="125" style="width: 235px;">
                </div>

                <div class="col-md-2 pad-top-5">
                    <span style="white-space: nowrap">Registry URL <span class="required">*</span></span>
                </div>
                <div class="col-md-10 pad-top-5">
                    <input placeholder="Valid url for remote ice instance" type="text" class="input_box"
                           ng-model="newPartner.url" maxlength="125" style="width: 235px;">
                </div>

                <br>

                <div class="col-xs-offset-2 col-md-10 pad_top">
                    <button type="submit" class="btn btn-xs btn-primary">Save</button>
                    <button type="button" ng-click="showAddRegistryForm=false; newPartner=undefined"
                            class="btn btn-xs btn-default">Cancel
                    </button>
                </div>
            </form>
        </div>
    </div>

    <div class="pad_top" ng-if="isWorEnabled && wor && wor.partners.length">
        <table cellspacing="0" class="table table-hover table-border-bottom font-95em" style="width: 98%">
            <thead>
            <tr>
                <th>&nbsp;</th>
                <th>
                    <span class="entry-table-header">Partner</span>
                </th>
                <th><span class="entry-table-header">Added</span></th>
                <th style="width: 150px"><span class="entry-table-header">Status</span></th>
                <th style="width: 120px">&nbsp;</th>
            </tr>
            </thead>
            <tbody>
            <tr ng-repeat="partner in wor.partners">
                <td style="vertical-align: middle; line-height:1; opacity:0.2; text-shadow:0 1px 0 #fff;"
                    class="font-14em">
                    <b>{{$index+1}}</b>
                </td>
                <td><a target="_blank" ng-href="https://{{partner.url}}">{{partner.name}}</a> <br>
                    <small class="color-888">{{partner.url}}</small>
                </td>
                <td style="vertical-align: middle">{{partner.addTime | date:'MMM d, y, h:mm a'}}</td>
                <!--lastContactTime-->
                <td style="vertical-align: middle">
                    <div class="btn-group" uib-dropdown>
                        <button type="button" class="btn btn-xs uib-dropdown-toggle strong" uib-dropdown-toggle
                                ng-class="{
                                'btn-success':partner.status === 'APPROVED',
                                'btn-warning':partner.status === 'PENDING',
                                'btn-danger':partner.status === 'BLOCKED'
                                }">
                            {{partner.status |capitalize}} <span class="caret"></span>
                        </button>
                        <ul class="uib-dropdown-menu">
                            <li ng-if="partner.status != 'BLOCKED'" ng-click="setPartnerStatus(partner, 'BLOCKED')">
                                <a class="font-90em" href="#">Block</a>
                            </li>
                            <li ng-if="partner.status != 'APPROVED'" ng-click="setPartnerStatus(partner, 'APPROVED')">
                                <a class="font-90em" href="#">Approve</a>
                            </li>
                        </ul>
                    </div>
                    &nbsp;
                    <i ng-if="partner.status == 'NOT_CONTACTED'" uib-tooltip="Retry"
                       ng-click="retryRemotePartnerContact()"
                       class="fa fa-fw fa-refresh fa-spin blue cursor_pointer opacity_hover"></i>
                </td>
                <td class="font-14em" style="vertical-align: middle">
                    <div class="pull-right">
                        <i class="fa fa-fw fa-refresh edit_icon"
                           ng-if="partner.status=='APPROVED' && !partner.refreshing"
                           ng-click="refreshPartner(partner)" uib-tooltip="Refresh"></i>
                        <i class="fa fa-fw fa-refresh opacity_3 fa-spin"
                           ng-if="partner.status=='APPROVED' && partner.refreshing"></i>
                        &nbsp;
                        <i class="fa fa-fw fa-trash-o fa-fw delete_icon" uib-tooltip="Delete"
                           ng-click="removePartner(partner, $index)"></i>
                    </div>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
</div>